// 字典相关
import { axiosInstance } from 'src/boot/axios'
import CommonConfig from 'src/assets/js/config'
// import Qs from 'qs'

const schemaUrl = CommonConfig.schemaUrl + '/v1'

/**
 * 通过code值不同，获取不同的字典数据
 * 2：部门属性
 * process_type 类别
 * **/
export function getDict (code, disable = true) {
  const newUrl = schemaUrl + '/dict_by_gcode'
  const params = {
    dicGroupCode: code,
    disable: disable
  }

  return axiosInstance.get(newUrl, { params }).then((res) => {
    return Promise.resolve((res))
  })
}

/**
 * 通过code值不同，获取不同的字典数据
 * 增加字段,filter:void 过滤掉非机加工设备
 * author: wfax
 * **/
export function getDictFilter (code, disable = true) {
  const newUrl = schemaUrl + '/dict_by_gcode/filter'
  const params = {
    dicGroupCode: code,
    disable: disable,
    filter: 'void'
  }

  return axiosInstance.get(newUrl, { params }).then((res) => {
    return Promise.resolve((res))
  })
}

/**
 * 根据厂区id，获取车间
 * plantId 厂区id
 * **/
export function getWorkshops (plantId) {
  const newUrl = CommonConfig.schemaUrl + '/v1' + '/workshop_kv'
  const params = {
    plantId
  }

  return axiosInstance.get(newUrl, { params }).then((res) => {
    return Promise.resolve((res))
  })
}
